﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Exercises.Actions
{
    public class MessageFilterAttribute : ActionFilterAttribute
    {
        public string Message { get; set; }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (!filterContext.Canceled && filterContext.Exception == null)
            {
                ((ViewResult)filterContext.Result).ViewData["Message"] = Message;
            }
        }
    }
}
